<template>
  <div class="searchBox">
    <header>
      <ul>
        <li @click="goback"><i class="iconfont icon-zuojiantou"></i></li>
        <li>
          <van-search
            v-model="value"
            placeholder="搜索您想住的区域或小区"
            background="inherit"
            @search="getSearch()"
          />
        </li>
      </ul>
    </header>
    <nav>
      <h2>热门搜索</h2>
      <ul>
        <li v-for="(item, index) in hotList" :key="index" @click="hotS(item)">
          {{ item }}
        </li>
      </ul>
    </nav>
    <div class="history">
      <h2>历史搜索</h2>
      <button>清除搜索记录</button>
    </div>
  </div>
</template>

<script>
// import { Search } from 'vant';
export default {
  data() {
    return {
      value: "",
      hotList: [
        "光谷",
        "洪山",
        "江岸",
        "江汉",
      ],
    };
  },
  methods: {
    goback() {
      this.$router.push("/home");
    },
    getSearch() {
      // console.log(this.value);
      let obj = {
        city: window.localStorage.getItem("city"),
        community: this.value,
        area: this.value,
        pagenum: 1,
        pagesize: 100,
      };
      this.$store.commit("uploadsearchParams", obj);
      this.$router.push("/searchDetails");
    },
    hotS(val) {
      this.value = val
    }
  },
};
</script>

<style scoped lang='less'>
* {
  margin: 0;
  padding: 0;
}
.searchBox {
  min-height: 1334px;
  background-color: #efefef;
}
header {
  height: 88px;
  width: 100%;
  background-color: rgb(255, 86, 86);
  ul {
    display: flex;
    li {
      line-height: 88px;
      &:nth-child(1) {
        // margin-left: 20px;
        width: 80px;
        text-align: center;
        i {
          color: #fff;
          font-size: 34px;
          line-height: 88px;
        }
      }
      &:nth-child(2) {
        border-radius: 10px;
        overflow: hidden;
        margin-top: 16px;
      }
      .van-search {
        border-radius: 5px;
        padding: 0;
        width: 600px;
        .van-search__content {
          height: 56px;
          border-radius: 8px;
          /deep/.van-field__control {
            font-size: 26px;
            color: #8f8f8f;
            line-height: 46px;
          }
          /deep/.van-icon {
            font-size: 26px;
            color: #8f8f8f;
            font-weight: bold;
            line-height: 46px;
          }
        }
      }
    }
  }
}
h2 {
  padding-top: 30px;
  margin-left: 40px;
  margin-bottom: 30px;
  color: #000;
  font-weight: 400;
  font-size: 24px;
}
nav {
  margin: 0 20px;
  box-shadow: 0 0 20px #ccc;
  background-color: #fff;
  border-radius: 8px;
  ul {
    margin: 0 40px;
    overflow: hidden;
    padding-bottom: 30px;
    li {
      float: left;
      list-style: none;
      width: 130px;
      height: 50px;
      border-radius: 8px;
      background-color: #e5e5e5;
      color: #000;
      text-align: center;
      line-height: 50px;
      font-size: 22px;
      margin-left: 35px;
      margin-bottom: 35px;
      &:nth-child(4n-3) {
        margin-left: 0;
      }
    }
  }
}
.history {
  button {
    margin: 0 40px;
    width: 670px;
    background-color: #fff;
    border: 0;
    border-radius: 12px;
    font-size: 24px;
    line-height: 80px;
  }
}
</style>